package com.cloudlinkscm.base.filecenter.client;

import com.cloudlinkscm.base.filecenter.client.service.FileService;
import com.cloudlinkscm.base.filecenter.model.dto.DeleteRequestDto;
import com.cloudlinkscm.base.filecenter.model.dto.DocumentUploadDto;
import com.cloudlinkscm.base.filecenter.model.dto.DownloadRequestDto;
import com.cloudlinkscm.base.filecenter.model.dto.ImageUploadDto;
import com.cloudlinkscm.base.filecenter.service.FileRemoteService;
import com.cloudlinkscm.loms.framework.core.pojo.RestfulApiResponse;
import com.cloudlinkscm.loms.framework.util.BeanUtils;
import org.apache.commons.beanutils.PropertyUtilsBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

/**
 * todo::
 *
 * @author : tac
 * @date : 2017/7/25
 */

@Component
public class FileClient implements FileRemoteService {
    @Autowired
    private FileService fileService;

    @Override
    public RestfulApiResponse<Map<String, String>> documentUrls(DownloadRequestDto dto) {
        return fileService.documentUrls(BeanUtils.extract(dto));
    }

    @Override
    public RestfulApiResponse<Map<String, String>> imageUrls(DownloadRequestDto dto) {
        return fileService.imageUrls(BeanUtils.extract(dto));
    }

    @Override
    public RestfulApiResponse<String> uploadDocument(MultipartFile file, DocumentUploadDto args) {
        return fileService.uploadDocument(file, BeanUtils.extract(args));
    }

    @Override
    public RestfulApiResponse<String> uploadImage(MultipartFile file, ImageUploadDto args) {
        return fileService.uploadImage(file, BeanUtils.extract(args));
    }

    @Override
    public RestfulApiResponse<Integer> delete(DeleteRequestDto dto) {
        return fileService.delete(BeanUtils.extract(dto));
    }
}
